package com.resolution.dietaryassessment.view.tcm.fragment;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.resolution.dietaryassessment.R;
import com.resolution.dietaryassessment.utils.FragAndActivityCommunication;


/**
 * @author By Resolusion
 * @Title: 中医体质测试简介
 * @Date: 2020/2/22
 * @Time: 21:56
 * @email Res01ution@foxmail.com
 */
public class TCMIntroductionFragment extends Fragment {
    private View view;

    private FragAndActivityCommunication callback;
    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        callback = (FragAndActivityCommunication) context;
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_introduction,container,false);
        initView();
        return view;
    }

    private void initView() {
        TextView tv = view.findViewById(R.id.tcm_type);

        SpannableString spannableString = new SpannableString("\u3000\u3000中医体质分为平和质、气虚质、" +
                "阳虚质、痰湿质、湿热质、血瘀质、气郁质、特禀质九个类型。");
        spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#ff0000")),
                8,spannableString.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        tv.setText(spannableString);

        Button mStart = view.findViewById(R.id.star_test);
        mStart.setOnClickListener(v -> callback.onNextFragment(true));
    }
}
